package farmer.game;

public class Mission {
	
	private final int timeByMission = 300*1000;
	private int timeForMission = timeByMission;
	private int missionObjective = 60;
	private double multiplier = 0.5;
	private int maxUpgrade = 70;
	
	public void update(int deltaTime){
		timeForMission -= deltaTime;
		if(timeForMission <= 0){
			timeForMission = timeByMission;
			completeMission();
		}
	}
	
	public int getTime(){
		return timeForMission/1000;
	}
	
	public int getFood(){
		return missionObjective;
	}
	
	private void completeMission(){
		Data.food -= missionObjective;
		if(Data.food < 0){
			Data.status = Data.failed;
		}else{
			Data.status = Data.victory;
		}
		int upgrade = (int) (missionObjective * multiplier);
		if(upgrade > maxUpgrade){
			upgrade = maxUpgrade;
		}
		missionObjective += upgrade;
	}

}
